package com.yang.game;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageButton;

import androidx.appcompat.app.AppCompatActivity;

import com.yang.game.model.Weapon;

public class ShopActivity extends AppCompatActivity {

    private ImageButton swordBtn;
    private ImageButton shieldBtn;
    private ImageButton weaponBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);
        swordBtn = findViewById(R.id.swordBtn);
        shieldBtn = findViewById(R.id.shieldBtn);
        weaponBtn = findViewById(R.id.weaponBtn);

        swordBtn.setOnClickListener(v -> {
            Weapon weapon = new Weapon(200, 40, 20);
            setWeapon(weapon);
        });

        shieldBtn.setOnClickListener(v -> {
            Weapon weapon = new Weapon(20, 30, 250);
            setWeapon(weapon);
        });


        weaponBtn.setOnClickListener(v -> {
            Weapon weapon = new Weapon(200, 10, 200);
            setWeapon(weapon);
        });

    }

    private void setWeapon(Weapon weapon) {
        Intent intent = new Intent();
        intent.putExtra("weapon", weapon);
        setResult(RESULT_OK, intent);
        finish();
    }
}
